package com.bj58.groupbuy.action.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bj58.groupbuy.action.db.CommonDao;
import com.bj58.groupbuy.action.db.DBConfig;
import com.bj58.groupbuy.action.model.HomeHeatMap;
import com.bj58.groupbuy.action.service.HeatMapService;

public class HeatMapServiceImpl implements HeatMapService{
	CommonDao commonDao = new CommonDao();

	public List<HomeHeatMap> getCityDataList(String stat_date,String cityPingyin,String platform){
		String tablename = "HomeHeatMap_"+stat_date.replace("-", "").substring(0,6);
		String sql = String.format("select * from %s where stat_date='%s' and cityPingyin='%s' and platform='%s'",tablename, stat_date,cityPingyin,platform);
		
		List<HomeHeatMap> rs;
		try {
			rs = commonDao.getAllColsByVo(sql, HomeHeatMap.class, DBConfig.db_131_data_bi.getIntType());
			return rs;
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	public Map<String, HomeHeatMap> getCityData(String stat_date,String cityPingyin,String platform){
		String tablename = "HomeHeatMap_"+stat_date.replace("-", "").substring(0,6);
		String sql = String.format("select * from %s where stat_date='%s' and cityPingyin='%s' and platform='%s'",tablename, stat_date,cityPingyin,platform);
		
		Map<String, HomeHeatMap> rsMap = new HashMap<String, HomeHeatMap>();
		List<HomeHeatMap> rs;
		try {
			rs = commonDao.getAllColsByVo(sql, HomeHeatMap.class, DBConfig.db_131_data_bi.getIntType());
			for(HomeHeatMap vo: rs){
				rsMap.put(vo.getClickID() , vo);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return rsMap;
	}
	
}
